<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<!--<link href="__ACSS__/style.css" rel="stylesheet" type="text/css" />-->
<script language="JavaScript" src="__AJS__/jquery.js"></script>
<link href="__ZTREE__/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="__ZTREE__/js/jquery.ztree.core-3.5.js"></script>
</head>
<body>
    <div class="formtitle"><span>基本信息</span></div>
        <form action="{:url()}" method="post">
            <table cellspacing="1" cellpadding="3" width="100%">
                <tr>
                    <td class="label">父分类</td>
                    <td>
                        <input type="hidden" name="cid" class="parent_id" maxlength="60" {empty name="$one_goods_specification['cid']"} value=""{else}value="{$one_goods_specification['cid']}"{/empty}>
                        <input type="text" name="parent_text" class="parent_text" disabled="disabled" {empty name="category_name"}value="默认为顶级分类"{else} value={$category_name}{/empty} maxlength="60">
                        <span style="color: red">*</span>
                    </td>
                </tr>
                <tr>
                    <td class="label"></td>
                    <td>
                        <ul id="treeDemo" class="ztree"></ul>
                    </td>
                </tr>
            </table><br>
            <input type="hidden" name="id" value="{$id}">
            规格名称： <input name="name" type="text" value="{$one_goods_specification['name']}"/><br><br>
            状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态：  <input type="radio" name="status" value="1" checked/>是 <input type="radio" name="status" value="0" />否<br><br>
           <input type="submit" value="确认保存"/>
        </form>
    </div>
</body>

<script language="javascript" type="text/javascript">
    $(document).ready(function(){
        //>>1.树的设置
        var setting = {
            data: {
                simpleData: {
                    enable: true,
                    pIdKey: "parent_id",
                }
            },
            callback: {
                onClick: function(event, treeId, treeNode){
                    //这是添加分类的id，到“input type="hidden" 里面
                    $('.parent_id').val(treeNode.id);
                    //这是添加分类的名称到”input type="text" name="parent_text"里面
                    $('.parent_text').val(treeNode.name);

                    //****这儿可以做ajax联动*******************
                    //获取选择的分类
                    //var id = $(".parent_id").val();
                }
            }
        };
        //>>2.准备树中需要的数据
        var zNodes ={$nodes};
        //>>3.将id为treeDemo的ul变为一个树, 返回值就是该树的对象
        var treeObject = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
        //>>4.使用对象中的方法让其展开
        treeObject.expandAll(true);
    });
</script>
</html>
